<script lang="ts" setup name="WorkType">
  import lang from './lang';
  import {
    addWorkType,
    delWorkType,
    pageWorkType,
    updateWorkType,
    exportWorkType,
  } from '@/api/base/workType';
  import { useMixins } from '@/hooks/useMixins';

  const { loadLangFn } = useMixins();

  const dfPageListRef: any = ref(null);

  loadLangFn(lang);

  const pageOptions = {
    searchForm: {
      formSchemas: [
        {
          label: 'workTypeName',
          component: 'NInput',
        },
        {
          label: 'workTypeCode',
          component: 'NInput',
        },
      ],
    },
    table: {
      hasSelection: true,
      columns: [
        {
          width: 120,
          label: 'workTypeName',
        },
        {
          width: 120,
          label: 'workTypeCode',
        },
        {
          width: 120,
          label: 'remark',
          common: true,
        },
      ],
      action: {
        columns: [
          {
            label: 'edit',
          },
          {
            label: 'delete',
          },
        ],
      },
      operaColumn: [
        {
          label: 'add',
        },
        {
          label: 'export',
        },
      ],
      rowKey: 'workTypeCode',
      requestFn: pageWorkType,
      delRequestFn: delWorkType,
      exportRequestFn: exportWorkType,
    },
    modalFormDialog: {
      formSchemas: [
        {
          label: 'workTypeName',
          editDialogDisabled: true,
          required: true,
        },
        {
          label: 'workTypeCode',
          editDialogDisabled: true,
          required: true,
        },
        // {
        //   label: 'standardHour',
        //   component: 'NInputNumber',
        //   componentProps: {
        //     maxlength: 50,
        //     min: 0,
        //     precision: 0,
        //     clearable: true,
        //     showButton: false,
        //   },
        // },
        {
          label: 'standardCost',
          component: 'NInputNumber',
          componentProps: {
            maxlength: 50,
            min: 0,
            precision: 0,
            clearable: true,
            showButton: false,
          },
        },
        {
          label: 'remark',
          common: true,
          type: 'textarea',
        },
      ],
      addDataFn: addWorkType,
      updateDataFn: updateWorkType,
    },
  };

  // nextTick(() => {
  //   dfPageListRef.value && dfPageListRef.value.openModalFn();
  // });
</script>

<template>
  <div class="paramConfig">
    <DFPageList ref="dfPageListRef" :page-options="pageOptions" />
  </div>
</template>
